//
//  BookMallMainCell.m
//  LiteraryTune
//
//  Created by Mr.Xy on 2018/11/21.
//  Copyright © 2018 cxd. All rights reserved.
//

#import "BookMallMainCell.h"
#import "HomeMenuModel.h"

@implementation BookMallMainCell
{
    UIImageView *_iconImageView;
    UILabel *_titleLabel;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setupUI];
        
        [self layoutUI];
    }
    return self;
}

- (void)setAdapterViewModel:(HomeMenuModel *)adapterViewModel {
    
    _adapterViewModel = adapterViewModel;
    
    _iconImageView.image = [UIImage imageNamed:adapterViewModel.imageName];
    _titleLabel.text = adapterViewModel.moduleName;
}

- (void)setupUI {
    
    _iconImageView = [[UIImageView alloc] init];
    _iconImageView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_iconImageView];
    
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.font = [UIFont systemFontOfSize:13];
    _titleLabel.textColor = [UIColor colorFromHexCode:@"#999999"];
    [self.contentView addSubview:_titleLabel];
}

- (void)layoutUI {
    
    [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_centerY).offset(15);
        make.centerX.equalTo(self.contentView.mas_centerX);
        make.height.width.equalTo(@44);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView.mas_centerX);
        make.top.equalTo(_iconImageView.mas_bottom).offset(10);
    }];
}
@end
